package models

import (
	"codeless/utils"
	"strconv"
	"strings"
)

func md5Format(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return ""
	}
	return utils.Md5(data)
}
func hashFormat(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return ""
	}
	return utils.HashAndSalt(data)
}
func likeFormat(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return ""
	}
	return utils.SqlLike(data)
}
func leftLikeFormat(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return ""
	}
	return utils.LeftLike(data)
}
func rightLikeFormat(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return ""
	}
	return utils.RightLike(data)
}

func dayRInt(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return 0
	}
	dayInt, _ := strconv.ParseInt(strings.ReplaceAll(data, "-", ""), 10, 64)
	return dayInt
}
func dayPInt(val interface{}) interface{} {
	data, ok := val.(string)
	if !ok {
		return 0
	}
	return utils.Str2Date(data)
}
